package org.example.controller;

import jakarta.annotation.Resource;
import org.example.interceptor.IsLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    @Resource
    private IsLoginInterceptor isLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(isLoginInterceptor)
                .addPathPatterns("/**")  // 哪些请求拦截
                .excludePathPatterns("/user/login");   // 哪些请求不拦截
    }
}
